package com.icity.controller.media;


import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.icity.common.Result;
import com.icity.entity.media.AppUser;
import com.icity.entity.system.TableSupport;
import com.icity.service.MediaService;
//广告统计
@RestController
@RequestMapping(value = "/admin/mediastatistical")
public class MediaController {

	@Autowired
	private MediaService mediaService;

	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/mediatable")
	@ResponseBody
	public Result getArticleList(HttpServletRequest request) {
		int page = Integer.parseInt(request.getParameter("page"));
		int limit = Integer.parseInt(request.getParameter("limit"));
		String author_name = request.getParameter("authorName");
		Map<Object,Object> map = new HashMap<Object,Object>();
		if (!author_name.equals("undefined")) {
			map.put("author_name", author_name);
		}
		Result result = new Result();
		try {
			map.put("page", (page-1)*limit);
			map.put("limit", limit);
			TableSupport<AppUser> list = (TableSupport<AppUser>) mediaService.getAppUserList(map);
			result.setCode("1");
			result.setMessage("获取成功");
			result.setData(list);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			result.setCode("-1");
			result.setMessage("获取数据异常");
			return result;
		}
	}
}
